﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using JM.JCY.Common;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.Document.ViewAllTemplateDocument
{
    public partial class ViewAllTemplateDocumentUserControl : UserControl
    {
        string listName = JCYConstant.SharePointListName.PublicTemplateDocumentLibrary;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SPWeb web = SPContext.Current.Web;
                SPList docList = web.Lists[listName];
                this.lvTemplateDocument.ListId = docList.ID.ToString();
                lvTemplateDocument.ViewId = docList.Views["All"].ID.ToString();
                string onclick = string.Format("javascript:NewItem2(event, '{0}');javascript:return false;", docList.DefaultNewFormUrl);
                this.idHomePageNewItem.Attributes.Add("onclick", onclick);

                if (CommonFunction.IsApplicationAdmin(20))
                    this.idHomePageNewItem.Visible = true;
                else
                    this.idHomePageNewItem.Visible = false;

            }
        }

         
    }
}
